package com.swanclouds.redfish.systems.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.redfish.common.redfish.MemberModel;
import com.swanclouds.redfish.common.utils.StringHepler;

import java.util.List;
import java.util.Map;

/**
 * BIOS 信息
 *
 * @author 张立强
 *  
 */
public class Bios {

    @JsonProperty("Id")
    private String id;

    @JsonProperty("Name")
    private String name;

    @JsonProperty("Description")
    private String description;

    @JsonProperty("AttributeRegistry")
    private String attributeRegistry;

    @JsonProperty("Attributes")
    private Map<String,String> attributes;

    @JsonProperty("Actions")
    private BiosActions actions;

    @JsonProperty("@Redfish.Settings")
    private RedfishSettings redfishSettings;

    /**
     * BIOS 资源的Id
     *
     * @return id
     */

    public String getId() {
        return this.id;
    }

    /**
     * BIOS 资源的名称
     *
     * @return name
     */

    public String getName() {
        return this.name;
    }

    /**
     * BIOS 资源的描述信息
     *
     * @return description
     */

    public String getDescription() {
        return this.description;
    }

    /**
     * BIOS 属性注册资源ID
     *
     * @return attributeRegistry
     */

    public String getAttributeRegistry() {
        return this.attributeRegistry;
    }

    /**
     * BIOS 属性列表
     *
     * @return attributes
     */
    public Map<String, String> getAttributes() {
        return this.attributes;
    }

    /**
     * Redfish 允许的 BIOS 资源可执行操作
     *
     * @return actions
     */
    public BiosActions getActions() {
        return this.actions;
    }

    /**
     * BIOS 设置资源信息
     * @see com.swanclouds.model.systems.Bios.RedfishSettings
     * @return redfishSettings
     */

    public RedfishSettings getRedfishSettings() {
        return this.redfishSettings;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setAttributeRegistry(String attributeRegistry) {
        this.attributeRegistry = attributeRegistry;
    }

    public void setAttributes(Map<String, String> attributes) {
        this.attributes = attributes;
    }

    public void setActions(BiosActions actions) {
        this.actions = actions;
    }

    public void setRedfishSettings(RedfishSettings redfishSettings) {
        this.redfishSettings = redfishSettings;
    }

    @JsonRootName("Actions")
    public static class BiosActions {

        @JsonProperty("#Bios.ChangePassword")
        private ChangePassword changePassword;

        @JsonProperty("#Bios.ResetBios")
        private ResetBios resetBios;

        public ChangePassword getChangePassword() {
            return this.changePassword;
        }

        public void setChangePassword(ChangePassword changePassword) {
            this.changePassword = changePassword;
        }

        public ResetBios getResetBios() {
            return this.resetBios;
        }

        public void setResetBios(ResetBios resetBios) {
            this.resetBios = resetBios;
        }

        @JsonRootName("#Bios.ChangePassword")
        public static class ChangePassword {

            private String target;

            @JsonProperty("@Redfish.ActionInfo")
            private String actionInfo;

            public String getTarget() {
                return this.target;
            }

            public void setTarget(String target) {
                this.target = target;
            }

            public String getActionInfo() {
                return this.actionInfo;
            }

            public void setActionInfo(String actionInfo) {
                this.actionInfo = actionInfo;
            }
        }

        @JsonRootName("#Bios.ResetBios")
        public static class ResetBios {
            private String target;
            @JsonProperty("@Redfish.ActionInfo")
            private String actionInfo;

            public String getTarget() {
                return this.target;
            }

            public void setTarget(String target) {
                this.target = target;
            }

            public String getActionInfo() {
                return this.actionInfo;
            }

            public void setActionInfo(String actionInfo) {
                this.actionInfo = actionInfo;
            }
        }
    }

    @JsonRootName("@Redfish.Settings")
    public static class RedfishSettings {

        @JsonProperty("@odata.type")
        private String type;

        @JsonProperty("SettingsObject")
        private MemberModel settingsObject;

        @JsonProperty("ETag")
        private String eTag;
        @JsonProperty("Messages")
        private List<String> messages;
        @JsonProperty("Time")
        private String time;


        public String getType() {
            return this.type;
        }


        public String getSettingsObject() {
            return settingsObject != null && StringHepler.isNotBlank(settingsObject.getDataId()) ? settingsObject.getDataId() : null;
        }


        public List<String> getMessages() {
            return this.messages;
        }


        public String getTime() {
            return this.time;
        }


        public String toString() {
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                return objectMapper.writeValueAsString(this);
            } catch (JsonProcessingException e) {
            }
            return "RedfishSettingsModel {" +
                    "type='" + type + '\'' +
                    ", settingsObject=" + settingsObject +
                    ", messages=" + messages +
                    ", time='" + time + '\'' +
                    '}';
        }
    }


    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "Bios {" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", attributeRegistry='" + attributeRegistry + '\'' +
                ", attributes=" + attributes +
                ", actions=" + actions +
                ", redfishSettings=" + redfishSettings +
                '}';
    }
}
